from typing import BinaryIO

from HTMLTestRunner_cn import HTMLTestRunner
import unittest
import os
import time


BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
REPORTS_PATH = os.path.join(BASE_PATH, r'H:\tool2\pycharm\PyCharm 2020.1\hd54_group1_poject3\reports')
"""测试报告命名"""
now = time.strftime("%Y%m%d%H%M%S")
report_name = os.path.join(REPORTS_PATH, "test-crm-{}.html".format(now))
"""定义测试目录文件"""
test_dir = "./cases/test_count_cases"
"""用discover进行"""
discover = unittest.defaultTestLoader.discover(test_dir, pattern="case*.py")

f = open(report_name, "wb")
runner = HTMLTestRunner(
    stream=f,
    title="墨白的统计分析模块",
    description="用例执行情况")

runner.run(discover)
f.close()
